﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record DeleteUserAccountCommand(long Id) : IRequest<bool>;

    public class DeleteUserAccountCommandHandler : IRequestHandler<DeleteUserAccountCommand, bool>
    {
        private readonly IUserAccountService _userAccountService;
        public DeleteUserAccountCommandHandler(IUserAccountService userAccountService) 
            => _userAccountService = userAccountService;

        public async Task<bool> Handle(DeleteUserAccountCommand request, CancellationToken cancellationToken)
        {
            await _userAccountService.DeleteAsync(request.Id);

            return true;
        }
    }
}
